package com.firestone.dao.primary.center;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.firestone.bean.dto.manager.ManagerDTO;
import com.firestone.bean.entity.mysql.primary.ImCenterManager;

/**
 * <p>
 * 产业地图后端管理中心管理员表 Mapper 接口
 * </p>
 *
 * @author CAIYJ
 * @since 2018-03-29
 */
public interface ImCenterManagerDao extends BaseMapper<ImCenterManager> {

    @Select("<script>  "
            + "SELECT cm.id, cm.username, cm.real_name, cm.is_delete, cm.create_time, cm.update_time, cm2.real_name AS create_user, cm1.real_name AS update_user, cr.role_name "
            + "FROM im_center_manager AS cm "
            + "LEFT JOIN im_center_manager_r_role AS mrr ON mrr.manager_id = cm.id "
            + "LEFT JOIN im_center_role AS cr ON cr.id = mrr.role_id "
            + "LEFT JOIN im_center_manager AS cm1 ON cm1.id = cm.reviser "
            + "LEFT JOIN im_center_manager AS cm2 ON cm2.id = cm.creator "
            + "<where> ${ew.sqlSegment} </where> </script> ")
    <T> List<ManagerDTO> selectManagerList(Pagination pagination,
            @Param("ew") Wrapper<T> wrapper);
}
